import axios from "./config";

// 前后端通讯
// axios.defaults.withCredentials = true

// 定义基础地址
// axios.defaults.baseURL = "/api"


/* const addComment = (username,password) => axios.post("/users/login", {
    username,
    password
},{ 
    headers: {
        "content-type":"application/json"
    }
}) */


// 定义请求接口
/**
 * 
 * @param {String} username 用户名
 * @param {String} password 密码
 * @returns Void
 */




export const loginApi = (username,password) => axios.post("/users/login", {
    username,
    password
});

// 获取验证码

export const getCaptchaApi = () => axios.get("/users/getCaptcha")


// 效验验证码

export const verifyCaptcha = (captcha="") => axios.get("/users/verifyCaptcha",{
    params: {
        captcha
    }
})

// 获取微信二维码地址url

export const getQrcodeUrlApi = (sid) => axios.get("/users/getQrcode", {
   params: {
       sid
   } 
})

// 微信登录
export const wechatLoginApi = (wechatCode) => axios.get("/users/wechatLogin", {
    params: {
        wechatCode
    }
})

// 获取权限菜单((路由)
export const getMenulistApi = () => axios.get("/permission/getMenuList")


// 获取登录日志

export const getLoginLogApi = (componentInstance,page=1,count = 15) => axios.get("/getloginlog", {
    params: {
        page,
        count
    }
})

// 获取学员列表
/**
 * 
 * @param {Number} page 页码
 * @param {Number} count 每页显示的数量
 * @param {Number} classes 班级
 * @returns {Promise} 返回一个promise的方法
 */
export const getStuListApi = (page=1,count=10,classes="")=> axios.get("/students/getstulist", {
    params:{
        page,
        count,
        class: classes
    }
})
